﻿using OF.Component.BLL;
using OF.Component.Model;
using OF.Utility;
using OpSystem.common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OpSystem.manage.city
{

    public partial class CityList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckPageCode("10202");
            if (!Page.IsPostBack)
            {
                BindProvince();
                MyBind();
            }
        }

        private void MyBind()
        {
            int intCount = 0;
            string whereStr = "  LocationGeographyTypeId = 1 and LocationStatus=1";
            int ProvinceID = EConvert.ToInt(this.ddlProvince.SelectedValue);
            if (ProvinceID > 0)
            {
                whereStr += " and LocationParentID=" + ProvinceID;
            }
            var list = BaseLocationOperate.Search(out intCount, AspNetPager1.CurrentPageIndex,
                                        AspNetPager1.PageSize, whereStr, "locationId", false);
            rptList.DataSource = list;
            rptList.DataBind();
            AspNetPager1.RecordCount = intCount;
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            MyBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            MyBind();
        }

        /// <summary>
        /// 省份职级
        /// </summary>
        /// <param name="ddlLocation"></param>
        public void BindProvince()
        {
            IList<BaseLocationInfo> list = BaseLocationOperate.QueryList(a => a.LocationID >0 && a.LocationStatus == 1);
            this.ddlProvince.DataSource = list;
            this.ddlProvince.DataTextField = "LocationName";
            this.ddlProvince.DataValueField = "LocationID";
            this.ddlProvince.DataBind();
        }
    }
}
